<template>
  <div class="msgStepOne-container" style="background:#f0f0f0;">
    <div class="content-part" style="background:#fff;">
    <!-- 医生信息 end -->
    <doctorMsg ref='doctorMsg'></doctorMsg>
    <!-- 患者来源 start -->
      <patientFrom @getpatientMsgone="getpatientInfo"></patientFrom>
    <!-- 患者来源 end -->
    </div>
    <div class="btn-box">
      <div class="weui-btn weui-btn_primary" :class="ischecked?'':'weui-btn_disabled'" @click="gotoNextStep">下一步</div>
    </div>
  </div>
</template>

<script>
import patientFrom from '@/views/components/patientFrom/patientFrom'
import doctorMsg from '@/views/components/doctorInfo/doctorInfo'
import docImg from '@/assets/images/doc.png'
import { getDocInfo } from '@/api/dialog'
import cookie from '@/utils/cookie'
export default {
  mounted() {
  },
  data () {
    return {
      // 获取医生的userid，通过this.$route获得
      patientSourceInfo:{},
      patientOpenid: '',
    }
  },
  methods: {
    // 点击按钮进入到下一步
    // 并且将患者来源信息上交到数据库保存
    gotoNextStep () {
      if(!this.ischecked) {
        return false
      }
      // 将患者信息保存到store里面的
      this.$store.commit('updatepatientOneInfo',this.patientSourceInfo)
      // 添加路由到第二步
      // 上传一个参数，主用用来获取医生信息数据
      this.$router.push({path:'/dialog/parientInfo',query:{openid:this.openid,doctorid: this.doctorid}})
    },
    // 获得从患者来源组件传过来的数据
    getpatientInfo (param) {
      this.patientSourceInfo = param
      this.patientSourceInfo.openid = this.openid
    }
  },
  computed: {
    ischecked () {
      return this.patientSourceInfo.sourceDesc ? true : false
    },
    openid () {
      let openid = this.$route.query.openid
      return openid
    },
    doctorid () {
      let doctorid = this.$route.query.doctorid
      return doctorid
    }
  },
  components: {
    patientFrom,
    doctorMsg
  }
}
</script>

<style scoped lang="stylus">
  .msgStepOne-container
    padding: 0 10px 10px 10px
    .content-part
      padding: 10px 10px 0 10px
      background: #f1f1f1
    .btn-box
      box-sizing: border-box
      width: 100%
      .weui-btn
        border-radius: 20px
        border: none
        width: 90%
        height: 37px
        text-align: center
        line-height: 37px
        margin: 20px auto 0
        color: #fff
        &.weui-btn_primary
          border: none
          background: #108ee9
        &.weui-btn_disabled
          border: none
          background: #c3e3f9
</style>
